<?php
	/**
	* Bill Manager - Request Cancel the Bill
	* @author: trungdt
	* @since: Oct 22, 2011
	* @version: 1.0
	* 
	*  
	* Change logs
	*/
	if (!defined('EXPONENT')) exit('');
    
    if (!exponent_users_isLoggedIn())
        die();

	$id=0;
    if (isset($_REQUEST['id']))
        $id=intval($_REQUEST['id']);
    
    productsmodule::__Bill_AddLogs("User {$user->firstname} {$user->lastname} ({$user->username}) request cancel bill #{$id}", $id);
    
    // send email to admin
    $headers['From'] =  SMTP_FROMADDRESS ;
    $headers['Reply-to'] = SMTP_FROMADDRESS;
    require_once(BASE.'subsystems/mail.php');
    $mail = null;
    $mail = new exponentMail();

    $mail->addTo(SMTP_FROMADDRESS);
    $mail->subject("Warning: User {$user->firstname} {$user->lastname} ({$user->username}) requested to cancel bill #{$id}");
    $mail->addText("Warning: User {$user->firstname} {$user->lastname} ({$user->username}) requested to cancel bill #{$id} at ".date('F j, Y, H:i:s',aboid_getCurrentTime()).". This request sent from IP Address ".$_SERVER['REMOTE_ADDR'].". Thanks.");
    $mail->addHeaders($headers);
    $mail->addFrom(SMTP_FROMADDRESS, SITE_TITLE );
    @$mail->send();
    
    echo exponent_lang_getText("bill_cancel_request_success");
    
    exponent_theme_setFlagAjaxAction(true);
?>
